<?php

namespace app\adminapi\controller\v1\portal;

use app\adminapi\controller\AuthController;
use app\services\portal\PortalMajorService;
use think\facade\App;

/**
 * 门户网站专业相关
 */
class PortalMajor extends AuthController
{

    public function __construct(App $app,PortalMajorService $service)
    {
        parent::__construct($app);
        $this -> services = $service;
    }

    public function index(){
        $where = $this->request->postMore([
            ['page', 1],
            ['pageSize', 20],
            ['website_id',$this  -> website],
        ]);
        return app() -> make('json') -> successful($this -> services -> index($where));
    }

    public function create(){
        $where = $this->request->postMore([
            ['title', ''],
            ['status', ''],
            ['content', ''],
            ['coverImg', ''],
            ['website_id',$this  -> website]
        ]);
        return app() -> make('json') -> successful($this -> services -> create($where));
    }
    public function update(){
        $where = $this->request->postMore([
            ['id', ''],
            ['title', ''],
            ['status', ''],
            ['content', ''],
            ['coverImg', '']
        ]);
        return app() -> make('json') -> successful($this -> services -> update($where));
    }
    public function delete(){
        $where = $this->request->postMore([
            ['id', ''],
        ]);
        return app() -> make('json') -> successful($this -> services -> delete($where));
    }

    public function searchTitle(){
        $where = $this->request->postMore([
            ['title', ''],
            ['page', 1],
            ['pageSize', 20],
            ['website_id',$this  -> website]

        ]);
        return app() -> make('json') -> successful($this -> services -> searchTitle($where));
    }

}